/*

 * 危急值上报后几分钟临床未确认自动提醒检验科电话通知
 */

<template>
    <rm-layout-top splitcolor="white" :splitwidth=5 :fixsize=35 :canDrag=false>
        <template v-slot:fix>
            <div style="height:35px;border:1px solid #CCC;padding:4px">
                <el-row>
                    <el-col :span="14">
                        <div class="grid-content bg-purple"> <span class="remind_class">以下危急值上报未确认，请关注！！</span></div>
                    </el-col>

                    <el-col :span="10">
                        <div class="grid-content bg-purple-light">
                            <el-button style="width:72px" @click.native="btnRefresh">刷新</el-button>
                            <el-button style="width:72px" @click.native="btnTelNotice">电话通知</el-button>
                            <el-button style="width:72px" @click.native="btnClose">退出</el-button>
                        </div>
                    </el-col>

                </el-row>
            </div>
        </template>
        <div style="height:100%">
            <vxe-table show-overflow ref="xTable" :data.sync="noconfirmData" height="auto" width="100%" border size="mini" :select-config="{ reserve: true }" show-header-overflow resizable header-align="center" :edit-config="{ trigger: 'click', mode: 'cell', showStatus: true, showIcon: false }" key="1" :cell-class-name="cellclassname" class="mytable-style" @current-change="currentChangeEvent" :loading="loading" @select-change="selectChange" @cell-dblclick="cellClick">
                <vxe-table-column type="selection" width="50" align="center"></vxe-table-column>
                <vxe-table-column field="rectelman" title="电话被通知人(双击弹窗)" width="90" align="center" :edit-render="{name:'input', autoselect: true}"></vxe-table-column>
                <vxe-table-column field="repeatflag" title="已复述" width="60" align="center">
                    <template v-slot="{row}">
                        <el-checkbox v-model="row.repeatflag" true-label="1" false-label="0"></el-checkbox>
                    </template>
                </vxe-table-column>
                <vxe-table-column field="rectelnum" title="通知电话号码" width="100" align="center" :edit-render="{name:'input', autoselect: true}"></vxe-table-column>
                 <vxe-table-column :field="item.field" :title="item.title" :width="item.width" v-for="item in tableListColumn" v-bind:key="item.field" sortable> </vxe-table-column>

<!--
                <vxe-table-column field="alertdt" title="上报时间" width="120"></vxe-table-column>
                <vxe-table-column field="alertman" title="上报人" width="60" align="center"></vxe-table-column>
                <vxe-table-column field="req_deptname" title="科室" width="100" align="center"></vxe-table-column>
                <vxe-table-column field="req_wardname" title="病区" width="100"></vxe-table-column>
                <vxe-table-column field="depttelnum" title="科室联系电话" width="90"></vxe-table-column>
                <vxe-table-column field="req_bedno" title="床号" width="60" align="center"></vxe-table-column>
                <vxe-table-column field="pat_no" title="病历号" width="90"></vxe-table-column>
                <vxe-table-column field="pat_name" title="姓名" width="60" align="center"></vxe-table-column>
                <vxe-table-column field="pat_sex" title="性别" width="50" align="center"></vxe-table-column>


                <vxe-table-column field="rpt_itemname" title="项目名称" width="120">
                </vxe-table-column>
                <vxe-table-column field="result_str" title="检验结果" width="80" align="center"></vxe-table-column>
                <vxe-table-column field="sampleno" title="样本号" width="90" align="center"></vxe-table-column>
                <vxe-table-column field="alertrules" title="违反的规则" width="100" align="center"></vxe-table-column>
                <vxe-table-column field="wardtelnum" title="病区联系电话" width="90" align="center"></vxe-table-column>
                <vxe-table-column field="alerttype" title="类别" width="70" align="center">
                    <template v-slot="{row}">
                        {{row.alerttype=='0'?"危急值":"多重耐药菌"}}
                    </template>
                </vxe-table-column>
                <vxe-table-column field="req_docname" title="开单医生" width="70" align="center"></vxe-table-column>
                <vxe-table-column field="result_ref" title="参考值" width="80">
                </vxe-table-column>
                <vxe-table-column field="result_unit" title="单位" width="70" align="center"></vxe-table-column>
                 <vxe-table-column field="rptunitname" title="报告单元" width="90" align="center"></vxe-table-column> -->
            </vxe-table>
        </div>

        <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="请选择电话被通知人" :visible.sync="dialogRectelman" width="600px">
            <rm-pop-common ref="popcom" @change="RectelnumChange" @cancel="dialogRectelman=false;" datatype="doctor"></rm-pop-common>
        </el-dialog>
    </rm-layout-top>
</template>

<script type="text/javascript">
export default {
    name: "rm_getnoconfirmalertinfo",
    props: {
        tabledata: { type: Array },
        params: { type: Object },
    },
    data() {
        return {
            noconfirmData: this.tabledata,
            loading: false,
            delay: { barcodes: "", delaykey: 0 },
            dialogRptDelay: false,
            dialogRectelman: false,
            selrow: {},
            loginflag: false,
            tableListColumn: [],
        };
    },
    created() {
        this.btnRefresh();
        //console.log("121", this.tabledata);
    },
    computed: {},
    watch: {},
    mounted() {},
    methods: {
        //获取自动提醒弹窗的选中行
        currentChangeEvent({ row, column }) {},
        //自动提醒弹窗列表的颜色
        cellclassname({ row, column }) {
            if (!["rectelman", "repeatflag", "rectelnum"].includes(column.property)) {
                return "col-pink";
            }
        },
        //电话通知
        btnTelNotice() {
            let data = this.$refs.xTable.getSelectRecords();
            if (data.length == 0) {
                this.$alert("请勾选要确认的危急值提醒，并录入相关信息！", "提示");
                return false;
            } else {
                if (this.loginflag) {
                    this.noconfirmtelnotice(data);
                } else {
                    this.$rm_Login({
                        type: "用户登录验证",
                        btn: {
                            confirmBtnText: "确定",
                            cancelBtnText: "取消",
                        },
                    })
                        .then((res) => {
                            if (res.flag == "1") {
                                //登录成功
                                this.noconfirmtelnotice(data);
                                this.loginflag = true;
                            } else {
                                //登录失败
                            }
                        })
                        .catch((e) => {
                            console.log("error", e);
                        });
                }
            }
        },
        //电话通知确认返回
        noconfirmtelnotice(data) {
            this.$tool
                .request({
                    url: "ucent/handlemsg",
                    method: "post",
                    data: {
                        action: "noconfirmtelnotice",
                        data: data,
                    },
                })
                .then((res) => {
                    if (res.errcode == "1") {
                        this.$alert("危急值确认成功，共计更新" + data.length + "条数据！", "提示").then(() => {
                            this.btnRefresh();
                        });
                    } else {
                        this.$alert(res.errmsg, "提示");
                    }
                })
                .catch((e) => {
                    console.log("error", e);
                });
        },
        selectChange({ row, column }) {
            row.rectelman = row.req_docname;//row.req_docno;
            //row.rectelmanname = row.req_docname;
            row.rectelnum = row.shortmsgcode;
        },
        cellClick({ row, column }) {
            if (column.property == "rectelman") {
                this.selrow = row;
                this.dialogRectelman = true;
            }
        },
        RectelnumChange(code, name, row) {
            this.selrow.rectelman = name;//code;
           // this.selrow.rectelmanname = name;
            this.selrow.rectelnum = row.shortmsgcode;
            this.dialogRectelman = false;
        },
        //刷新超时报告
        btnRefresh() {
            this.loading = true;
            this.$tool
                .request({
                    url: "ucent/alertmsg",
                    method: "post",
                    data: {
                        params: this.params.paramlist,
                    },
                })
                .then((res) => {
                    this.noconfirmData = res.data;
                    this.tableListColumn = res.cols;
                    this.loading = false;
                })
                .catch((e) => {
                    this.$alert(e, "提示");
                    this.loading = false;
                });
        },
        //退出
        btnClose() {
            this.$emit("change", "close");
        },
    },
};
</Script>

<style scoped>
.remind_class {
    color: rgb(236, 11, 11);
    font-size: 18px;
}
::v-deep .mytable-style .vxe-body--column.col-pink {
    background-color: pink;
    color: rgb(8, 8, 8);
}
</style>
